﻿#region Header
/*
 * name：MultilingualManager
 * author：Kain
 * date：12/3/2010 10:21:21 AM
 *********************************************
 * History:
 * $Header$
 * $History$
 */
#endregion

#region imported namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Compilation;
using System.Threading;
using System.Globalization;
#endregion

namespace Cherry.Agile.Globalization
{
    /// <summary>
    /// 多语言管理
    /// </summary>
	public static class MultilingualManager
	{
        static List<KeyValuePair<string, string>> __lng = new List<KeyValuePair<string,string>>();
        //static IResourceProvider __resourceProvider;
        static MultilingualManager()
        {
            __lng.Add(new KeyValuePair<string, string>("zh-CN", "简体中文"));
            __lng.Add(new KeyValuePair<string, string>("en-US", "English"));
            __lng.Add(new KeyValuePair<string, string>("it-IT", " Italiano"));


            //__resourceProvider = new ResourceProviderFactory().CreateGlobalResourceProvider(string.Empty);
        }

        /// <summary>
        /// 获取语言集合
        /// </summary>
        /// <returns></returns>
        public static List<KeyValuePair<string, string>> GetLanguages()
        {
            return __lng;
        }

        /// <summary>
        /// 切换语言
        /// </summary>
        /// <param name="cultureName"></param>
        public static void SwichCulture(string cultureName)
        {
            if( !string.IsNullOrEmpty(cultureName))
                System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);

            var en = System.Threading.Thread.CurrentThread.CurrentCulture;
            en = new CultureInfo(en.LCID);
            en.DateTimeFormat.ShortDatePattern = "yyyy-M-d";
            en.DateTimeFormat.LongTimePattern = "H:mm:ss";
            System.Threading.Thread.CurrentThread.CurrentCulture = en;
        }
	}
}
